<template>
  <div>
    <common-header></common-header>
    <search :list="list"></search>
    <bai-ke-list :list="list"></bai-ke-list>
    <go-top></go-top>
  </div>
</template>

<script>
  // 请求Ajax数据
  import axios from 'axios'

  import CommonHeader from 'common/commonheader/CommonHeader'
  import Search from './components/Search'
  import BaiKeList from './components/List'
  import goTop from '../../common/gotop/goTop'

  export default {
    name: 'BaiKe',
    data () {
      return {
        // 存储 JSON 数据
        list: []
      }
    },
    components: {
      CommonHeader,
      Search,
      BaiKeList,
      goTop
    },
    // 方法
    methods:{
      // 发送AjaX请求
      getRaidersInfo(){
        axios.get('/api/baikelist.json')
          .then(this.handeleGetRaidersInfoSucc)
      },
      handeleGetRaidersInfoSucc(res){
        console.log(res)
        res = res.data
        if (res.ret && res.data) {
          const data = res.data
          // 获取 JSON 数据，赋值给data 变量中
          this.list = data.List
        }
      }
    },
    mounted () {
      //当页面挂载时，执行该方法
      this.getRaidersInfo()
    }
  }
</script>

<style scoped>

</style>
